package SV_SSRF_URI;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;


public class Fixed {
    public class SV_SSRF_URI_POSITIVE_JAKARTA {
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, URISyntaxException, InterruptedException {
            HttpClient client = HttpClient.newHttpClient();

            // GOOD: the request parameter is validated against a known fixed string or valid source of IP address
            String url = req.getParameter("uri");
            if (VALID_URI.equals(url)) {
                URI uri = new URI(url);
                HttpRequest r = HttpRequest.newBuilder(uri).build();
                client.send(r, null);
            }
        }
}
